{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "隐式Sentence 2 Token的Labels方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def forward(self, input_ids, attention_mask):\n",
    "    outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)\n",
    "    \n",
    "    sequence_output = outputs.last_hidden_state  # 每个 token 的表示\n",
    "    pooled_output = outputs.pooler_output  # 句子级别的表示\n",
    "    \n",
    "    logits = self.classifier(pooled_output)  # 对句子分类\n",
    "    token_logits = self.classifier(sequence_output)  # 每个 token 的情感概率\n",
    "    \n",
    "    return logits, token_logits"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
